/**
 * 
 * @Project le cOeur - Data Virtualization
 * @Date 08.12.2012
 * @Author Aebi Pascal, Kocher Marc
 * @School BFH-TI Biel, Bachelor Thesis
 *
 */

package main.api.http;

/**
 * This class represents a component defined by the HTTP protocol (RFC-2616).
 */
public class Response extends Message {

	/**
	 * Creates a HTTP response.
	 * The created HTTP response needs to be parsed before the object can be used.
	 * The parsing should be done after all necessary message headers are added.
	 * 
	 * @param statusLine The The status line string containing the HTTP version, the HTTP status code and the HTTP reason phrase.
	 */
	public Response(String statusLine) {
		super(new StatusLine(statusLine));
	}
	
	/**
	 * Creates a HTTP response.
	 * 
	 * @param version The HTTP version.
	 * @param statusCode The HTTP status code.
	 * @param reasonPhrase The HTTP reason phrase.
	 */
	public Response(Version version, StatusCode statusCode, ReasonPhrase reasonPhrase) {
		super(new StatusLine(version, statusCode, reasonPhrase));
	}
	
	/**
	 * Returns the version of the HTTP response.
	 * 
	 * @return The HTTP version.
	 */
	public Version getVersion() {
		StatusLine statusLine = (StatusLine) super.startLine;
		return statusLine.getVersion();
	}

	/**
	 * Returns the status code of the HTTP response.
	 * 
	 * @return The HTTP status code.
	 */
	public StatusCode getStatusCode() {
		StatusLine statusLine = (StatusLine) super.startLine;
		return statusLine.getStatusCode();
	}

	/**
	 * Returns the reason phrase of the HTTP response.
	 * 
	 * @return The HTTP reason phrase.
	 */
	public ReasonPhrase getReasonPhrase() {
		StatusLine statusLine = (StatusLine) super.startLine;
		return statusLine.getReasonPhrase();
	}

}
